package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Ceshi;
import com.ruoyi.system.service.ICeshiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ceshiController
 * 
 * @author ruoyi
 * @date 2024-03-27
 */
@RestController
@RequestMapping("/system/ceshi")
public class CeshiController extends BaseController
{
    @Autowired
    private ICeshiService ceshiService;

    /**
     * 查询ceshi列表
     */
    @PreAuthorize("@ss.hasPermi('system:ceshi:list')")
    @GetMapping("/list")
    public TableDataInfo list(Ceshi ceshi)
    {
        startPage();
        List<Ceshi> list = ceshiService.selectCeshiList(ceshi);
        return getDataTable(list);
    }

    /**
     * 导出ceshi列表
     */
    @PreAuthorize("@ss.hasPermi('system:ceshi:export')")
    @Log(title = "ceshi", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Ceshi ceshi)
    {
        List<Ceshi> list = ceshiService.selectCeshiList(ceshi);
        ExcelUtil<Ceshi> util = new ExcelUtil<Ceshi>(Ceshi.class);
        util.exportExcel(response, list, "ceshi数据");
    }

    /**
     * 获取ceshi详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:ceshi:query')")
    @GetMapping(value = "/{bmname}")
    public AjaxResult getInfo(@PathVariable("bmname") String bmname)
    {
        return success(ceshiService.selectCeshiByBmname(bmname));
    }

    /**
     * 新增ceshi
     */
    @PreAuthorize("@ss.hasPermi('system:ceshi:add')")
    @Log(title = "ceshi", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Ceshi ceshi)
    {
        return toAjax(ceshiService.insertCeshi(ceshi));
    }

    /**
     * 修改ceshi
     */
    @PreAuthorize("@ss.hasPermi('system:ceshi:edit')")
    @Log(title = "ceshi", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Ceshi ceshi)
    {
        return toAjax(ceshiService.updateCeshi(ceshi));
    }

    /**
     * 删除ceshi
     */
    @PreAuthorize("@ss.hasPermi('system:ceshi:remove')")
    @Log(title = "ceshi", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bmnames}")
    public AjaxResult remove(@PathVariable String[] bmnames)
    {
        return toAjax(ceshiService.deleteCeshiByBmnames(bmnames));
    }
}
